package com.meichis.yndms.common;

import android.text.TextUtils;

import com.meichis.mcsappframework.utils.SharePreferenceUtil;
import com.meichis.mcsappframework.utils.Tools;
import com.meichis.yndms.MCApplication;
import com.meichis.yndms.model.UserInfo;

import java.util.UUID;

public class DataCenter {
    //液奶为1002
    public static final int Manufacturer = 1002;
    public static final String AppCode = "YLYN-BOSS";
    public static final String AdvPageCode = "HomePage_YNBOSS";
    private static UserInfo curUser;

    //需要全局替换成空的事业部名称
    public static final String Target = "液态奶事业部->";

    public static UserInfo getCurUser() {
        if (curUser==null){
            curUser = (UserInfo) SharePreferenceUtil.getInstance().getObjectValue(SharePreferenceUtil.PREFERENCES_USERINFO);
        }
        return curUser;
    }

    public static void setCurUser(UserInfo curUser) {
        DataCenter.curUser = curUser;
    }

    //设备ID
    private static String DeviceID = "";

    public static String getDeviceID() {
        if (TextUtils.isEmpty(DeviceID)) {
            DeviceID = Tools.getDeviceId(MCApplication.getContext());
            if (TextUtils.isEmpty(DeviceID) || DeviceID.equals("unknown")) {
                DeviceID = SharePreferenceUtil.getInstance().getStringValue(MCode.DEVICEID);
                if (TextUtils.isEmpty(DeviceID)) {
                    DeviceID = UUID.randomUUID().toString();
                }
                SharePreferenceUtil.getInstance().setStringValue(MCode.DEVICEID, DeviceID);
            }
        }
        return DeviceID;
    }
}
